package org.projectback.hanlder.exception;

import jakarta.validation.ValidationException;
import lombok.extern.slf4j.Slf4j;

import org.projectback.utils.ResultMessage;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;


@Slf4j
@ControllerAdvice
public class ValidationHandler {

    @ExceptionHandler(ValidationException.class)
    @ResponseBody
    public ResultMessage<Void> validateException( ValidationException e) {
        log.warn("Resolve[{},{}]",e.getClass().getName(),e.getMessage());
        return ResultMessage.failure(402,"请求参数有误");
    }

}
